<?php
    include APPLICATION_PATH . '/application/views/head.phtml';
    include APPLICATION_PATH . '/application/views/top.phtml';
    include APPLICATION_PATH . '/application/views/left.phtml';
?>
<div id="thispage" data-id="52"></div>



		<!-- BEGIN PAGE -->

		<div class="page-content">

			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<div id="portlet-config" class="modal hide">

				<div class="modal-header">

					<button data-dismiss="modal" class="close" type="button"></button>

					<h3>portlet Settings</h3>

				</div>

				<div class="modal-body">

					<p>Here will be a configuration form</p>

				</div>

			</div>

			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<!-- BEGIN PAGE CONTAINER-->

			<div class="container-fluid">

				<!-- BEGIN CHART PORTLETS-->

				<div class="row-fluid">

					<div class="span12">



						<!-- BEGIN INTERACTIVE CHART PORTLET-->

						<div class="portlet box red" style="margin-top: 30px;">

							<div class="portlet-title">

								<div class="caption"><i class="icon-reorder"></i>一周采集量统计</div>

							</div>

							<div class="portlet-body">

								<div id="chart_2" class="chart" style=" height: 500px;"></div>

							</div>

						</div>

						<!-- END INTERACTIVE CHART PORTLET-->                 

					</div>

				</div>

				<!-- END CHART PORTLETS-->



				<!-- END PAGE CONTENT-->

			</div>

			<!-- BEGIN PAGE CONTAINER-->     

		</div>

		<!-- END PAGE --> 

	</div>

	<!-- END CONTAINER -->

	<!-- BEGIN FOOTER -->

	<div class="footer">

		<div class="footer-inner">

			<!-- 2013 &copy; Metronic by keenthemes.Collect from <a href="http://www.cssmoban.com/" title="网站模板" target="_blank">网站模板</a> - More Templates <a href="http://www.cssmoban.com/" target="_blank" title="模板之家">模板之家</a>
 -->
		</div>

		<div class="footer-tools">

			<span class="go-top">

			<i class="icon-angle-up"></i>

			</span>

		</div>

	</div>

	<!-- END FOOTER -->

	<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->

	<!-- BEGIN CORE PLUGINS -->

	<script src="/public/js/jquery-1.10.1.min.js" type="text/javascript"></script>

	<script src="/public/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>

	<!-- IMPORTANT! Load jquery-ui-1.10.1.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->

	<script src="/public/js/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>      

	<script src="/public/js/bootstrap.min.js" type="text/javascript"></script>

	<!--[if lt IE 9]>

	<script src="/public/js/excanvas.min.js"></script>

	<script src="/public/js/respond.min.js"></script>  

	<![endif]-->   

	<script src="/public/js/jquery.slimscroll.min.js" type="text/javascript"></script>

	<script src="/public/js/jquery.blockui.min.js" type="text/javascript"></script>  

	<script src="/public/js/jquery.cookie.min.js" type="text/javascript"></script>

	<script src="/public/js/jquery.uniform.min.js" type="text/javascript" ></script>

	<!-- END CORE PLUGINS -->

	<!-- BEGIN PAGE LEVEL PLUGINS -->

	<script src="/public/js/jquery.flot.js"></script>

	<script src="/public/js/jquery.flot.resize.js"></script>

	<script src="/public/js/jquery.flot.pie.js"></script>

	<script src="/public/js/jquery.flot.stack.js"></script>

	<script src="/public/js/jquery.flot.crosshair.js"></script>

	<!-- END PAGE LEVEL PLUGINS -->

	<!-- BEGIN PAGE LEVEL SCRIPTS -->

	<script src="/public/js/app.js"></script>
	
	<!--<script src="/public/js/charts2.js"></script>      -->
	<script>
		var Charts = function () {

    return {
        //main function to initiate the module

        init: function () {

            App.addResponsiveHandler(function () {
                 Charts.initPieCharts(); 
            });
            
        },

        initCharts: function () {

            if (!jQuery.plot) {
                return;
            }

            var data = [];
            var totalPoints = 250;

            // random data generator for plot charts

            function getRandomData() {
                if (data.length > 0) data = data.slice(1);
                // do a random walk
                while (data.length < totalPoints) {
                    var prev = data.length > 0 ? data[data.length - 1] : 50;
                    var y = prev + Math.random() * 10 - 5;
                    if (y < 0) y = 0;
                    if (y > 100) y = 100;
                    data.push(y);
                }
                // zip the generated y values with the x values
                var res = [];
                for (var i = 0; i < data.length; ++i) res.push([i, data[i]])
                return res;
            }


            function chart2() {

                var pageviews = window.xyaxis;
function getT(beforedays){
    var bfd = beforedays || 0;
    var od = new Date();
    od.y = od.getFullYear();
    od.m = od.getMonth() + 1;
    od.d = od.getDate() - bfd;
    var arr = [31,29,31,30,31,30,31,31,30,31,30,31];
    if(od.d <= 0){   
        od.m = od.m-1;
        od.d = arr[od.m-1]+od.d;
    }
    return od.y+'年'+od.m+'月'+od.d+'日';
}
                var plot = $.plot($("#chart_2"), [{
                            data: pageviews,
                            label: "采集量"
                        }
                        // , {
                        //     data: visitors,
                        //     label: "Page Views"
                        // }
                    ], {
                        series: {
                            lines: {
                                show: true,
                                lineWidth: 2,
                                fill: true,
                                fillColor: {
                                    colors: [{
                                            opacity: 0.05
                                        }, {
                                            opacity: 0.01
                                        }
                                    ]
                                }
                            },
                            points: {
                                show: true
                            },
                            shadowSize: 2
                        },
                        grid: {
                            hoverable: true,
                            clickable: true,
                            tickColor: "#eee",
                            borderWidth: 0
                        },
                        colors: ["#d12610", "#37b7f3", "#52e136"],
                        xaxis: {
                            show: true,
                            tickDecimals: 0,
                            ticks: [[1, getT(6)], [2, getT(5)], [3, getT(4)], [4, getT(3)], [5, getT(2)], [6, getT(1)], [7, getT(0)]]
                        },
                        yaxis: {
                            show: true,
                            ticks: 16,
                            tickDecimals: 0
                        }
                    });


                function showTooltip(x, y, contents) {
                    $('<div id="tooltip">' + contents + '</div>').css({
                            position: 'absolute',
                            display: 'none',
                            top: y + 5,
                            left: x + 15,
                            border: '1px solid #333',
                            padding: '4px',
                            color: '#fff',
                            'border-radius': '3px',
                            'background-color': '#333',
                            opacity: 0.80
                        }).appendTo("body").fadeIn(200);
                }

                var previousPoint = null;
                $("#chart_2").bind("plothover", function (event, pos, item) {
                    $("#x").text(pos.x.toFixed(2));
                    $("#y").text(pos.y.toFixed(2));

                    if (item) {
                        if (previousPoint != item.dataIndex) {
                            previousPoint = item.dataIndex;

                            $("#tooltip").remove();
                            var x = item.datapoint[0].toFixed(2),
                                y = item.datapoint[1].toFixed(2);

                            showTooltip(item.pageX, item.pageY, item.series.label + " of " + x + " = " + y);
                        }
                    } else {
                        $("#tooltip").remove();
                        previousPoint = null;
                    }
                });
            }

            chart2();

        },

        initPieCharts: function () {

            var data = [];
            var series = Math.floor(Math.random() * 10) + 1;
            series = series < 5 ? 5 : series;
            
            for (var i = 0; i < series; i++) {
                data[i] = {
                    label: "Series" + (i + 1),
                    data: Math.floor(Math.random() * 100) + 1
                }
            }

            function pieHover(event, pos, obj) {
            if (!obj)
                    return;
                percent = parseFloat(obj.series.percent).toFixed(2);
                $("#hover").html('<span style="font-weight: bold; color: ' + obj.series.color + '">' + obj.series.label + ' (' + percent + '%)</span>');
            }

            function pieClick(event, pos, obj) {
                if (!obj)
                    return;
                percent = parseFloat(obj.series.percent).toFixed(2);
                alert('' + obj.series.label + ': ' + percent + '%');
            }

        }
        
    };

}();
	</script>

	<script>
	 <?php echo 'var collArticle_info=' . json_encode($collArticle_info, true) . ';'; ?>
		jQuery(document).ready(function() { 
			 var obj = collArticle_info;
                window.xyaxis = [
                    [1, obj[6][0]['counts']],
                    [2, obj[5][0]['counts']],
                    [3, obj[4][0]['counts']],
                    [4, obj[3][0]['counts']],
                    [5, obj[2][0]['counts']],
                    [6, obj[1][0]['counts']],
                    [7, obj[0][0]['counts']]
                ];
			 

		   // initiate layout and plugins

		   App.init();

		   Charts.init();

		   Charts.initCharts();

		   //Charts.initPieCharts();

		});

	</script>

	<!-- END PAGE LEVEL SCRIPTS -->

</body>

<!-- END BODY -->

</html>